#include "simulate_app.h"
#include <stdio.h>
#include "frame_src_composite.h"
#ifdef _WIN32
#include "frame_src_enc_h264.h"
#include"frame_src_enc_h265.h"
#endif
#include "frame_src_file.h"

CFrameSrcComposite g_frm_composite;
static CFrameSrcComonent* get_frame_src(int src_type)
{
    switch (src_type)
    {
    case SRC_FILE:
        return new CFrame_src_file();
        break;
#ifdef _WIN32
    case SRC_H264:
        return new CFrame_src_enc_h264();
        break;
    case SRC_H265:
        return new CFrame_src_enc_h265();
        break;
#endif
    }
    return NULL;
}

void simulate_src_open(int source_type,int stream_id, const char* file, int frm_rate)
{
    CFrameSrcComonent* pFrm_src = get_frame_src(source_type);
    int ret = pFrm_src->Open(file, stream_id);

    printf("simulate_file_open %s ret %d .\n",file ,ret);
      
    pFrm_src->set_frm_rate(frm_rate);
    g_frm_composite.add(pFrm_src);

    printf("add ");
}

void simulate_src_setres(int stream_id, int width, int height)
{
    g_frm_composite.get_comonent(stream_id)->set_video_res(width,height);
}

void simulate_src_setbitrate(int stream_id, int bitrate)
{
    g_frm_composite.get_comonent(stream_id)->set_bit_rate(bitrate);
}

void simulate_src_start()
{
    g_frm_composite.start();
}

void simulate_src_stop()
{
    g_frm_composite.stop();
}

void simulate_src_log(bool bEnable)
{
    g_frm_composite.show_log(-1,bEnable);
}